package MyDefault

import (
	"net/http"
	"strconv"

	"github.com/gin-gonic/gin"
)

type DefaultController struct {
}

func (D DefaultController) Login(ctx *gin.Context) {
	type User struct {
		Id   int    `json:"id"`
		Name string `json:"name"`
		Age  int    `json:"age"`
	}
	users := []User{}
	for i := 1; i <= 30; i++ {
		u := User{
			Id:   i,
			Name: "user" + strconv.Itoa(i),
			Age:  i,
		}
		users = append(users, u)
	}

	ctx.JSON(http.StatusOK, gin.H{
		"users": users,
	})
}

func (D DefaultController) GetUsers(ctx *gin.Context) {
	ctx.JSON(http.StatusOK, []gin.H{
		// 评论列表数据
		{
			"rpid": 3,
			"user": gin.H{
				"uid":   "13258165",
				"uname": "周杰伦",
			},
			"content": "哎哟，不错哦",
			"ctime":   "10-18 08:15",
			"like":    99,
		},
		{
			"rpid": 2,
			"user": gin.H{
				"uid":   "36080105",
				"uname": "许嵩",
			},
			"content": "我寻你千百度 日出到迟暮",
			"ctime":   "11-13 11:29",
			"like":    88,
		},
		{
			"rpid": 1,
			"user": gin.H{
				"uid":   "30009257",
				"uname": "黑马前端",
			},
			"content": "学前端就来黑马",
			"ctime":   "10-19 09:00",
			"like":    66,
		},
	})
}
func (D DefaultController) GetFoots(ctx *gin.Context) {
	ctx.JSON(http.StatusOK, []gin.H{
		{
			"tag":  "318569657",
			"name": "一人套餐",
			"foods": []gin.H{
				{
					"id":              8078956697,
					"name":            "烤羊肉串(10串)",
					"like_ratio_desc": "好评度100%",
					"month_saled":     40,
					"unit":            "10串",
					"food_tag_list":   []string{"点评网友推荐"},
					"price":           90,
					"picture":         "http://localhost/static/images/羊肉串.jpg",
					"description":     "",
					"tag":             "318569657",
					"count":           1,
				},
				{
					"id":              7384994864,
					"name":            "腊味煲仔饭",
					"like_ratio_desc": "好评度81%",
					"month_saled":     100,
					"unit":            "1人份",
					"food_tag_list":   []string{},
					"price":           39,
					"picture":         "http://localhost/static/images/煲仔饭.jpg",
					"description":     "",
					"tag":             "318569657",
					"count":           1,
				},
				{
					"id":              2305772036,
					"name":            "鸡腿胡萝卜焖饭",
					"like_ratio_desc": "好评度91%",
					"month_saled":     300,
					"unit":            "1人份",
					"food_tag_list":   []string{},
					"price":           34.32,
					"picture":         "http://localhost/static/images/鸡腿胡萝卜焖饭.jpg",
					"description":     "主料：大米、鸡腿、菜心、胡萝卜",
					"tag":             "318569657",
					"count":           1,
				},
				{
					"id":              2233861812,
					"name":            "小份酸汤莜面鱼鱼+肉夹馍套餐",
					"like_ratio_desc": "好评度73%",
					"month_saled":     600,
					"unit":            "1人份",
					"food_tag_list":   []string{"“口味好,包装很好～点赞”"},
					"price":           34.32,
					"picture":         "http://localhost/static/images/酸汤鱼.jpg",
					"description":     "酸汤莜面鱼鱼，主料：酸汤、莜面 肉夹馍，主料：白皮饼、猪肉",
					"tag":             "318569657",
					"count":           1,
				},
			},
		},
		{
			"tag":  "82022594",
			"name": "特色烧烤",
			"foods": []gin.H{
				{
					"id":              3823780596,
					"name":            "藤椒鸡肉串",
					"like_ratio_desc": "",
					"month_saled":     200,
					"unit":            "10串",
					"food_tag_list": []string{
						"点评网友推荐",
					},
					"price":       6,
					"picture":     "http://localhost/static/images/藤椒鸡肉串.jpg",
					"description": "1串。藤椒味，主料：鸡肉",
					"tag":         "82022594",
					"count":       1,
				},
				{
					"id":              6592009498,
					"name":            "烤羊排",
					"like_ratio_desc": "",
					"month_saled":     50,
					"unit":            "1人份",
					"food_tag_list":   []string{},
					"price":           169,
					"picture":         "http://localhost/static/images/烤羊排.jpg",
					"description":     "6-8个月草原羔羊肋排，烤到皮脆肉香",
					"tag":             "82022594",
					"count":           1,
				},
			},
		},
		{
			"tag":  "98147100",
			"name": "杂粮主食",
			"foods": []gin.H{
				{
					"id":              4056954171,
					"name":            "五常稻花香米饭",
					"like_ratio_desc": "",
					"month_saled":     1000,
					"unit":            "约300克",
					"food_tag_list":   []string{},
					"price":           5,
					"picture":         "http://localhost/static/images/五常稻花香米饭.jpg",
					"description":     "浓浓的稻米清香，软糯Q弹有嚼劲",
					"tag":             "98147100",
					"count":           1,
				},
				{
					"id":              740430262,
					"name":            "小米发糕(3个)",
					"like_ratio_desc": "好评度100%",
					"month_saled":     100,
					"unit":            "3块",
					"food_tag_list":   []string{},
					"price":           13,
					"picture":         "http://localhost/static/images/小米发糕.jpg",
					"description":     "柔软蓬松，葡萄干和蔓越莓酸甜适口",
					"tag":             "98147100",
					"count":           1,
				},
				{
					"id":              7466390504,
					"name":            "沙枣玉米窝头(3个)",
					"like_ratio_desc": "好评度100%",
					"month_saled":     100,
					"unit":            "3个",
					"food_tag_list":   []string{},
					"price":           13,
					"picture":         "http://localhost/static/images/沙枣玉米窝头.jpg",
					"description":     "",
					"tag":             "98147100",
					"count":           1,
				},
			},
		},
	})
}
